1. Field of Invention
The present invention relates to a virtual machine technique, and in particular to a method and apparatus for dynamically assigning input/output device in virtual machine system.
2. Description of Prior Art
At present, it is more and more common to run multiple operating systems (OS) on servers simultaneously. This is a standard function on Unix OS and host computers introduced by IBM, Sun and HP Incs. Various OSs can run individual tasks at optimal performance, while there is no interference between the tasks. This technique has been implanted onto x86 architecture based computer systems by Intel and AMD Incs. A new research made by Gartner Inc shows that virtualization is the most powerful technique in PC industry in the next decade. By separating software from hardware and allowing multiple OSs running on the same desktop, the virtualization technique in PC industry will bring a revolution in enterprise desktops.
Virtualization allows a platform to run multiple OSs in individual partitions or “devices”. A physical computing system could operate as multiple “virtual” systems. A user can perform individual partitioning on separated platforms, thus the risk of virus on one partition infecting other partitions or even the whole network could be reduced.
FIG. 1 is a structural diagram of a prior art virtual machine system, which includes a service operating system (service OS), at least one guest operating systems (guest OS), and a hypervisor (virtual machine monitor, also referred to VMM), wherein the service OS comprises a device model, a control panel, and a native device driver. The control panel is used to create a guest OS, delete a guest OS, and specify device information for the configuration file of a guest OS. As each guest OS being created, a corresponding configuration file and a device model are generated. Based on the configuration file, the device model sets the enabled and disabled states of the devices in a guest OS corresponding to it. A guest OS searches hardware upon startup, obtaining device configuration information of the guest OS from a device model through a hypervisor. The device model situated on a service OS provides the corresponding guest OS with full hardware platform information, i.e. a virtual hardware platform. All the hardware devices “seen” by a guest OS are virtualized by a device model. A hypervisor provides a guest OS with a channel for accessing device models. All the access, requests, and various operations for hardware devices by a guest OS are passed to device models through the hypervisor. Then, the device models interact with hardware through a real hardware drive, and pass the response and operating results of the hardware to the guest OS through the hypervisor. Thus, real hardware devices can be normally accessed by a guest OS.
The key of virtualization is to provide various OSs with individual and separated hardware platforms. This technique is implemented mainly by software due to the limit of hardware in PC. However, the implementation in prior art could only assign I/O devices statically. If the configuration of I/O devices in a virtual system need to be changed, a configuration file in a Control Panel must to be modified firstly, then the system will be rebooted in order to carry the configuration into effect. Therefore, flexible assigning of I/O devices in a virtual system is limited.